package net.jadfreex.crawler.web.jsoup.input;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import org.apache.log4j.Logger;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class Parser {

    private Logger log = Logger.getLogger(this.getClass());

    private void parseHTML(String html) throws IOException {
	Document doc = Jsoup.parse(html);
	log.info(doc.html());
    }

    private void parseURL(URL url) {
	try {
	    Document doc = Jsoup.parse(url, 3000);
	    log.info(doc.html());
	} catch (IOException e) {
	    e.printStackTrace();
	}
    }

    private void parseURL(String url) {
	try {
	    URL obj = new URL(url);
	    this.parseURL(obj);
	} catch (MalformedURLException e) {
	    e.printStackTrace();
	}
    }

    public static void main(String[] args) throws IOException {
	Parser parser = new Parser();
	parser.parseHTML("<html><head><title>Jajaja</title></head><body><p>Hola</p><td> mundo </td></body></html>");
	parser.parseURL("http://coj.uci.cu");
    }
}